<?php

namespace app\admin\model;

use think\Model;

/**
 * Contract
 */
class Contract extends Model
{
    // 表名
    protected $name = 'contract';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;


    public function getFilesAttr($value): array
    {
        if ($value === '' || $value === null) return [];
        if (!is_array($value)) {
            return explode(',', $value);
        }
        return $value;
    }

    public function setFilesAttr($value): string
    {
        return is_array($value) ? implode(',', $value) : $value;
    }

    public function operationTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\emp\Emp::class, 'operation', 'id');
    }

    public function reviewerTable(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\emp\Emp::class, 'reviewer', 'id');
    }
}